package LeetCode._01_树;

public class _222_完全二叉树的节点个数 {
    public class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
   }

    public int countNodes(TreeNode root) {
        if(root == null) return 0;

        int left = countNodes(root.left);
        int right = countNodes(root.right);

        int count = left + right + 1;
        return count;
    }
}
